include([
 'renderers.Renderer'
 , 'renderers.NodeRenderer'
 , 'materials.Material'
 , 'shapes.Quad'], 

function(){

	declare('renderers.BoundingBoxRenderer');
	
	BoundingBoxRenderer = NodeRenderer.extend({
		includeChildren : false,
		material        : Material.create({name:'BoundingBoxMaterial', strokeStyle:'red', lineWidth:.25}),
		init : function(name, includeChildren){
			this._super(name || 'BoundingBoxRenderer' + (Renderer.count++));
			this.includeChildren = includeChildren;
		},
		renderObject : function(gw, obj){
			if( obj.boundingBox ){
				var box = obj.boundingBox()
				var m = obj.material || this.material;
				m.render(gw, Quad.fromPoints(box.min, box.max));
			}
			if( this.includeChildren && obj.node ){
				var backup = this.material;
				this.material = obj.node.material || backup;
				this.renderNode(gw, obj.node);
				this.material = backup;
			}			
			/*if( this.includeChildren && obj.children ){
				for(var e in obj.children ){
					if( obj.children[e] ) this.renderObject(gw, obj.children[e]);
				}
			}*/		
			return true;
		}
	});

});